main(List<String> args) {
  //=====================Person相关=====================
  final Person1 = Person("why", 18);
  print("${Person1.name} ${Person1.age}");
  Map<String, dynamic> info = {"name": "why", "age": 30, "height": 1.98};
  final Person2 = Person.fromMap(info);
  //=====================Person相关=====================
  final r = Rectangle(20, 30);
  print(r);
}

class Person {
  String name;
  int age;
  double height;

  //普通写法
  Person(String name, [int age, double height]) {
    this.name = name;
    this.age = age;
    this.height = height;
  }

  //语法糖写法
  //Person(String s, {this.name, this.age, this.height});

  Person.fromMap(Map<String, dynamic> map) {
    this.name = map["name"];
    this.age = map["age"];
    this.height = map["height"];
  }

  void eating() {
    print(name + "在吃东西");
  }
}

class Rectangle {
  int width;
  int height;
  int area;

  Rectangle(this.width, this.height) {
    this.area = area;
    this.height = height;
    this.area = width * height;
  }
  @override
  String toString() {
    // TODO: implement toString
    return "width: $width height: $height area: $area";
  }
}
